package com.lxy.sentinel.config;

import com.alibaba.csp.sentinel.adapter.spring.webmvc.callback.RequestOriginParser;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;

/**
 * @author lixinyang
 * @className: RequestOriginParserDefinition
 * @description: TODO
 * @date 2022/04/28日  22:02
 */
@Component
public class RequestOriginParserDefinition implements RequestOriginParser {
    /**
     *  定义从请求的什么地方获取来源信息
     *  比如我们可以要求所有的客户端需要在请求头中携带来源信息
     */
    @Override
    public String parseOrigin(HttpServletRequest httpServletRequest) {
        String serviceName = httpServletRequest.getParameter("serviceName");
        return serviceName;
    }
}
